﻿using System;
using ilgolosone.Shared.Domain;

namespace ilgolosone.DomainModel.ValueObjects
{
    [Serializable]
    public class AddressInfo : ValueObject<AddressInfo>
    {
        private string _address;
        private string _postalCode;
        private string _city;
        private string _region;

        public AddressInfo()
            : this(string.Empty, string.Empty, string.Empty, string.Empty)
        { }

        public AddressInfo(string address, string postalCode, string city, string region)
        {
            Address = address;
            PostalCode = postalCode;
            City = city;
            Region = region;
            
            RegisterProperty(val => val.Address);
            RegisterProperty(val => val.PostalCode);
            RegisterProperty(val => val.City);
            RegisterProperty(val => val.Region);
        }

        public string Address
        {
            get { return _address; }
            private set 
            {
                _address = value;
            }
        }

        public string PostalCode
        {
            get { return _postalCode; }
            private set 
            {
                _postalCode = value;
            }
        }

        public string City
        {
            get { return _city; }
            private set
            {
                _city = value;
            }
        }

        public string Region
        {
            get { return _region; }
            private set 
            {
                _region = value;
            }
        }

        public override string ToString()
        {
            return string.Format("{0} {1} {2} ({3})", Address, PostalCode, City, Region);
        }
    }
}
